package kr.hkit.test.ch27.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectDatabase {
	public static Connection makeConnection(){
		String driver = "com.mysql.jdbc.Driver"; //두문자 D
		String url = "jdbc:mysql://localhost:3306/erp";
		String id = "root";
		String password = "1111";
		Connection con = null;
		
		try {
			Class.forName(driver);		
			System.out.println("드라이버 적재 성공");
			con = DriverManager.getConnection(url, id, password);
			System.out.println("데이터베이스 연결 성공");
		} catch (ClassNotFoundException e) {
			System.out.println("드라이버를 찾을 수 없습니다");
		} catch (SQLException e) {
			System.out.println("연결에 실패하였습니다");
		}
		
		return con;
	}
	public static void main(String[] args) {
		Connection con = makeConnection();
	}
}
